package com.wangzeqi.neihanduanzi.enter;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.wangzeqi.neihanduanzi.R;

/**
 * Created by dllo on 16/1/22.
 */
public class SuggestionActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView textView,textView2;
    private EditText editText1, editText2;
    private Handler handler;
    private Thread newThread;         //声明一个子线程
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.suggestion_activity);
        findViewById(R.id.btn_root).setOnClickListener(this);
        textView = (TextView) findViewById(R.id.send_root);
        textView2 = (TextView) findViewById(R.id.message_root);
        textView.setOnClickListener(this);
        editText1 = (EditText) findViewById(R.id.edt1);
        editText2 = (EditText) findViewById(R.id.edt2);
    }

    @Override
    public void onClick(View v) {
        textView.setVisibility(View.VISIBLE);
        editText1.setText("");
        String tx = String.valueOf(editText2.getText());
        editText2.setText(" ");
        textView.setText(tx);
       sendMessage();
    }
    public void sendMessage() {

        handler = new Handler(new Handler.Callback() {
            public boolean handleMessage(Message msg) {
                textView2.setVisibility(View.VISIBLE);
                return false;
            }
        });
        new Thread() {
            @Override
            public void run() {
                try {
                    sleep(2000);
                    handler.sendEmptyMessage(0);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
}
